﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace CIT.WMS.houseWork.Bll
{
    public class Bll_InventoryDetail_tid
    {
        /// <summary>
        /// 校验料盘编码
        /// </summary>
        /// <param name="varInventory"></param>
        /// <param name="varReelid"></param>
        /// <param name="varMsg"></param>
        /// <returns></returns>
        public static bool CheckBarCode(string varInventoryCode, string varReelid, out string varMsg)
        {
            string sqlcmd = string.Format(@"
declare @Qty nvarchar(50)
if not exists(select *  from T_InventoryDetail_tid where InventoryCode='{0}' and  ReelId='{1}')--不存在
    begin
       select '0','料盘编码不存在盘点单中' return                                        
    end
else--存在
    begin
       select @Qty=Qty from T_InventoryDetail_tid where InventoryCode='{0}' and ReelId='{1}'
       select '1','Success',@Qty as 'Qty' return
    end", varInventoryCode, varReelid);
            DataTable dt_BarCode = Utils.NMS.QueryDataTable(Utils.uContext, sqlcmd, new CIT.WMS.MESWcf.CmdParameter[0]);
            if (dt_BarCode.Rows[0][0].ToString() == "0")
            {
                varMsg = dt_BarCode.Rows[0][1].ToString();
                return false;
            }
            varMsg = dt_BarCode.Rows[0]["Qty"].ToString();
            return true;
        }
    }
}
